package com.example.temp.mapper;

import com.example.temp.entity.Role;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface RoleMapper {
    @Select("SELECT * FROM ROLE WHERE id = #{id}")
    Role findById(Integer id);
    
    @Select("SELECT * FROM ROLE")
    List<Role> findAll();
    
    @Update("UPDATE ROLE SET description = #{description} WHERE id = #{id}")
    int updateRole(Role role);
    
    @Insert("INSERT INTO ROLE(id, name, description) VALUES(#{id}, #{name}, #{description})")
    int addRole(Role role);
    
    @Delete("DELETE FROM ROLE WHERE id = #{id}")
    int deleteRole(Integer id);
}
